package kandl.automation.reporting.testrail.model;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonValue;

public enum TestRailStatus {
    success(1),
    blocked(2),
    untested(3),
    retest(4),
    fail(5);

    private final int value;

    TestRailStatus(int value) {
        this.value = value;
    }

    @JsonValue
    public int getValue(){
        return value;
    }

    @JsonCreator
    public static TestRailStatus fromValue(int status) {
        for(TestRailStatus testRailStatus : TestRailStatus.values()) {
            if(testRailStatus.getValue() == status) {
                return testRailStatus;
            }
        }
        throw new RuntimeException("Unknown status cannot be read from json");
    }
}
